package com.zl.smartmall.library.vo;

import java.util.List;

import net.tsz.afinal.FinalDb;
import android.content.Context;

import com.zl.smartmall.library.po.BrandedProductsInfo;

public class BrandedProductsInfoDao {

	private FinalDb mFinalDb;
	
	public BrandedProductsInfoDao(Context context){
		mFinalDb = FinalDb.create(context);
	}
	
	public void insert(List<BrandedProductsInfo> models) {
		for(BrandedProductsInfo model : models) {
			model.encode();
		}
		mFinalDb.batchSave(models);
	}
	
	public void delete() {
		mFinalDb.deleteByWhere(BrandedProductsInfo.class, null);
	}
	
	public void delete(int activitiesId) {
		mFinalDb.deleteByWhere(BrandedProductsInfo.class, "activitiesId=" + activitiesId);
	}
	
	public List<BrandedProductsInfo> query() {
		List<BrandedProductsInfo> models = mFinalDb.findAll(BrandedProductsInfo.class);	
		for(BrandedProductsInfo model : models) {
			model.decode();
		}
		return models;
	}
	
	public List<BrandedProductsInfo> query(int activitiesId) {
		List<BrandedProductsInfo> models = mFinalDb.findAllByWhere(BrandedProductsInfo.class, "activitiesId=" + activitiesId);	
		for(BrandedProductsInfo model : models) {
			model.decode();
		}
		return models;
	}

}
